﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WifiChannel
{

    
    /// <summary>
    /// This class implements the wifi server
    /// </summary>
    public class WifiChannel : vppServer.vppserver
    {

        int Port { set; get; }
        String Ip { set; get; }

        BiomedicaLib.communication.channels.Source.UDP _udp = new BiomedicaLib.communication.channels.Source.UDP();


        public WifiChannel()
        {
           
           
        }
       
      
        /// <summary>
        /// Open Channel, Ignored
        /// </summary>
        public override void OpenChannel()
        {
            
            
            
        }

        void _udp_SensEnded(object sender, SensingFinishedEventHandlerArg e)
        {
            String msg = e.IncmeMSg;
            base.DoMessage(msg);
           
        }

        public override void CloseChannel()
        {
            _udp.Deinitialize();
        }

        public override void SendCode(string Code)
        {
            _udp.SendRequest(Code);
        }

        public override void StartListning()
        {
            _udp.Listin();
        }

        public override void Initalise()
        {
            _udp.Initilize(4444, 4445);
            _udp.SensEnded += new EventHandler<SensingFinishedEventHandlerArg>(_udp_SensEnded);
        }

        public override void Deinitalise()
        {
            _udp.Deinitialize();
            
        }

        public void setIP(System.Net.IPAddress iPAddress)
        {
           
        }
        public void setIP(String iPAddress)
        {
            Ip = iPAddress;
        }
    }
}
